
import Mock from 'mockjs'

const HTTP_CONSTS = {
  AuthKey: {
    ADMIN: "GTMC-ADMIN-TOKEN",
  },
  OPENID_KEY: "OpenId",
  CODE: {
    SUCCESS: 10000000,
    AUTH_ERROR: 70008,
  },
  HttpMethod: {
    PST: 'post',
    GET: 'get',
    PUT: 'put',
    DEL: 'delete',
    POST: 'post',
    DELETE: 'delete',
  }
}


/******
 * 
 * 表格字段，单行三点
 * 
 */

const MOCK_ID = '@natural(1000000000000000000, 2000000000000000000)'
const MOCK_NUM = 'N@natural(1000000000000000000, 2000000000000000000)'
const MOCK_CNAME = '@ctitle(2,16)'
const MOCK_CODE = '@string("upper", 9, 9)'
const MOCK_DESCRIPTION = '@cparagraph(3)'
const MOCK_DATETIME = '@datetime("yyyy-MM-dd HH:mm:ss")'
const MOCK_PRICE = '@float(0, 1000, 0, 6)'
const MOCK_IMAGE = '@image("50x50", "#324157", "#FFF", "png", "M")'
const MOCK_USER = '@cname'
const MOCK_MOBILE = '@natural(15800000000, 15900000000)'
const MOCK_STATUS = '@natural(1, 6)'
const MOCK_TYPE = '@natural(1, 6)'
const MOCK_SORT = '@natural(1, 1000)'
const MOCK_QUANTITY = '@natural(1, 100)'
const MOCK_BOOLEAN = '@boolean(5, 5, true)'


function getMockEntity(firstId) {
  return {
    "versionId|+1": parseInt(firstId),
    "seriesCode": '@string("lower", 10, 10)',
    "name": MOCK_CNAME,
    "code": '@integer(0)', //随机整数
    "description": MOCK_DESCRIPTION,
    "status": MOCK_STATUS,
    "createBy": '@string("lower", 10, 30)',
    "createTime": MOCK_DATETIME,
    "updateBy": '@string("lower", 10, 30)',
    "updateTime": MOCK_DATETIME,  
    'region': '@province - @city', //生成一个大区
    "adminName": MOCK_USER,
    "position": '@ctitle(4,5)',

    "vehName": '@ctitle(5,7)',
    "vehNameCode": '@string("upper", 6, 6)',
    "modelCode": '@string("upper", 5, 5)-@string("upper", 5, 5)',

    "manualId": MOCK_ID,
    "itemId": MOCK_ID,
    "itemName": MOCK_CNAME,
    "seriesId": MOCK_ID,
    "partsTypeId": MOCK_ID,

    "partsId": MOCK_ID,
    "partsName": MOCK_CNAME,
    "partsCode": MOCK_CODE,
    "partsTypeName": MOCK_CNAME,
    "suggestPrice": MOCK_PRICE,
    "iconPath": MOCK_IMAGE,
    "tipsPaths": `["${MOCK_IMAGE}","${MOCK_IMAGE}"]`,
    "orderNo": MOCK_NUM,
    "agencyName": MOCK_CNAME,
    "jobOrderNo": MOCK_NUM,
    "completionTime": MOCK_DATETIME,
    "omsOrderNo": MOCK_NUM,
    "omsThirdPartySerialNo": MOCK_NUM,
    "receivableAmount": MOCK_PRICE,
    "moneyReceived": MOCK_PRICE,
    "discountAmount": MOCK_PRICE,


    "maintainOrderNo": MOCK_NUM,
    "vehicleName": MOCK_CNAME,
    "maintainName": MOCK_CNAME,
    "customerName": MOCK_USER,
    "customerPhoneNumber": MOCK_MOBILE,


    "username": MOCK_CODE,
    "fullName": MOCK_USER,
    "mobile": MOCK_MOBILE,

    "articleId": MOCK_ID,
    "typeName": MOCK_CNAME,
    "scenarioName": MOCK_CNAME,
    "scenarioId": MOCK_ID,
    "title": MOCK_CNAME,
    "content": MOCK_DESCRIPTION,

    maintainManualId: MOCK_ID,
    entityId: MOCK_ID,
    eventId: "",
    eventType: MOCK_TYPE,
    manualId: MOCK_ID,
    manualItemRules: [],
    manualItems: [],
    manualType: "",
    modelCode: MOCK_CODE,
    name: MOCK_CNAME,
    sort: MOCK_SORT,
    vehName: MOCK_CNAME,
    vehNameCode: MOCK_CODE,

    manualType: MOCK_TYPE,

    "itemDetails": [
      {
        itemId: "10001",
        itemName: MOCK_CNAME,
        description: MOCK_DESCRIPTION,
        manItemId: MOCK_ID,
        "manItemParts|5": [
          {
            createBy: MOCK_CNAME,
            createTime: MOCK_DATETIME,
            itemId: MOCK_ID,
            manItemId: MOCK_ID,
            manItemPartsId: MOCK_ID,
            partsCode: MOCK_CODE,
            partsId: MOCK_ID,
            partsName: MOCK_CNAME,
            partsTypeName: MOCK_CNAME,
            sort: MOCK_TYPE,
            srpPrice: MOCK_PRICE,
            updateBy: MOCK_CNAME,
            updateTime: MOCK_DATETIME,
            useQuantity: MOCK_QUANTITY,
          }
        ],
        selected: MOCK_BOOLEAN,
        sort: MOCK_SORT,
      },
      {
        itemId: MOCK_ID,
        itemName: MOCK_CNAME,
        description: MOCK_DESCRIPTION,
        manItemId: MOCK_ID,
        "manItemParts|5": [
          {
            createBy: MOCK_CNAME,
            createTime: MOCK_DATETIME,
            itemId: MOCK_ID,
            manItemId: MOCK_ID,
            manItemPartsId: MOCK_ID,
            partsCode: MOCK_CODE,
            partsId: MOCK_ID,
            partsName: MOCK_CNAME,
            partsTypeName: MOCK_CNAME,
            sort: MOCK_TYPE,
            srpPrice: MOCK_PRICE,
            updateBy: MOCK_CNAME,
            updateTime: MOCK_DATETIME,
            useQuantity: MOCK_QUANTITY,
          }
        ],
        selected: MOCK_BOOLEAN,
        sort: MOCK_SORT,
      }
    ],
    ruleDetails: [
      {
        "condMileages": [
          5000, 35000
        ],
        itemId: "10001",
        itemName: MOCK_CNAME,
        manItemId: MOCK_ID,
      }
    ],


    "ordPartsItemVos|5": [
      {
        actualPrice: MOCK_PRICE,
        imagePath: MOCK_IMAGE,
        orderItemId: MOCK_ID,
        orderItemNum: MOCK_NUM,
        partsGoodsId: MOCK_ID,
        partsGoodsName: MOCK_DESCRIPTION,
        quantity: MOCK_QUANTITY,
        salePrice: MOCK_PRICE,
        srpPrice: MOCK_PRICE,
        status: MOCK_STATUS,
        "couponCode": MOCK_NUM,
      }
    ],
    orderId: MOCK_ID,
    orderNum: MOCK_NUM,
    actualAmount: MOCK_PRICE,
    buyerName: MOCK_USER,
    buyerMobile: MOCK_MOBILE,
    buyerVehName: MOCK_CNAME,
    buyerLicensePlateNum: MOCK_CODE,
    storeName: MOCK_CNAME,
    storeCode: MOCK_CODE,

    ordPaymentVo: {

      omsOrderNo: MOCK_NUM,
      omsThirdPartySerialNo: MOCK_NUM,
    },
    buyerMessage: MOCK_DESCRIPTION,
    refundReason: MOCK_DESCRIPTION,
    refundAmount: MOCK_PRICE,

    buyerLicensePlateNum: MOCK_CODE,
    buyerModelCode: MOCK_CODE,
    buyerVehFrameCode: MOCK_CODE,
    storeName: MOCK_CNAME,
    storeCode: MOCK_CODE,
    storeAddress: MOCK_DESCRIPTION,
    orderAmount: MOCK_PRICE,
    scheduledTime: MOCK_DATETIME,

    //工单字段

    jobOrderNo: MOCK_NUM,
    completeTime: MOCK_DATETIME,
    arrivalTime: MOCK_DATETIME,
    // storeName: MOCK_CNAME,
    // verifyCode: MOCK_DATETIME,
    totalAmount: MOCK_PRICE,
    discountAmount: MOCK_PRICE,
    actualAmount: MOCK_PRICE,
    isMonthlyPaid: MOCK_BOOLEAN,


    verifyJobOrderNum: MOCK_NUM,
    verifyJobOrderId: MOCK_ID,
    verifyCode: MOCK_CODE,
    usedTime: MOCK_DATETIME,
    scheduledTime: MOCK_DATETIME,
    goodsQuantity: MOCK_QUANTITY,
    paymentTime: MOCK_DATETIME,
    "scenarioSimple|3": [{
      name: MOCK_CNAME,
    }],



    "ordPartsItemGroupVos|3": [
      {
        verifyJobOrderNum: MOCK_NUM,
        verifyJobOrderId: MOCK_ID,
        verifyCode: MOCK_CODE,
        usedTime: MOCK_DATETIME,
        status: MOCK_STATUS,
        scheduledTime: MOCK_DATETIME,
        goodsQuantity: MOCK_QUANTITY,
        "ordPartsItemVos|3": [
          {
            actualPrice: MOCK_PRICE,
            imagePath: MOCK_IMAGE,
            orderItemId: MOCK_ID,
            orderItemNum: MOCK_NUM,
            partsGoodsId: MOCK_ID,
            partsGoodsName: MOCK_DESCRIPTION,
            quantity: MOCK_QUANTITY,
            salePrice: MOCK_PRICE,
            srpPrice: MOCK_PRICE,
            status: MOCK_STATUS,
          }
        ],
      }
    ],
    "ordVirtualItemVo": {
      actualPrice: MOCK_PRICE,
      imagePath: MOCK_IMAGE,
      orderItemId: MOCK_ID,
      orderItemNum: MOCK_NUM,
      partsGoodsId: MOCK_ID,
      partsGoodsName: MOCK_DESCRIPTION,
      quantity: MOCK_QUANTITY,
      salePrice: MOCK_PRICE,
      srpPrice: MOCK_PRICE,
      status: MOCK_STATUS,
      couponCode: MOCK_NUM,
    }

    ,
    "maintainItemDetails|6": [{
      iconPath: MOCK_IMAGE,
      itemId: MOCK_ID,
      itemName: MOCK_CNAME,
      matItemId: MOCK_ID,
      sort: MOCK_QUANTITY,
      "matItemParts|3": [{
        actualPrice: MOCK_PRICE,
        itemId: MOCK_ID,
        itemName: MOCK_CNAME,
        matItemId: MOCK_ID,
        matItemPartsId: MOCK_ID,
        partsCode: MOCK_CODE,
        partsId: MOCK_ID,
        partsName: MOCK_CNAME,
        partsTypeName: MOCK_CNAME,
        salePrice: MOCK_PRICE,
        sort: MOCK_QUANTITY,
        suggestPrice: MOCK_PRICE,
        useQuantity: MOCK_QUANTITY,
      }],
    }],
    "ordMatPkgVo": {
      maintainName: MOCK_CNAME,
    },

    token: "sfasdfasdf",
    resourceDetails: [
      { "code": "1010101", },
      { "code": "1010201", },
      { "code": "1010202", },
      { "code": "1010203", },
      { "code": "1010204", },
      { "code": "1010205", },
      { "code": "1010206", },
      { "code": "1010207", },
      { "code": "1010208", },
      { "code": "1010209", },
      { "code": "1010210", },
      { "code": "1010211", },
      { "code": "1010212", },
      { "code": "1010301", },
      { "code": "1010302", },
      { "code": "1010303", },
      { "code": "1010304", },
      { "code": "1010305", },
      { "code": "1010306", },
      { "code": "1010307", },
      { "code": "1010308", },
      { "code": "1010309", },
      { "code": "1010310", },
      { "code": "1010311", },
      { "code": "1010312", },
      { "code": "1010313", },
      { "code": "1010314", },
      { "code": "1010315", },
      { "code": "1020101", },
      { "code": "1020102", },
      { "code": "1020103", },
      { "code": "1020104", },
      { "code": "1020105", },
      { "code": "1020106", },
      { "code": "1020107", },
      { "code": "1020108", },
      { "code": "1020109", },
      { "code": "1020201", },
      { "code": "1020202", },
      { "code": "1020203", },
      { "code": "1020204", },
      { "code": "1020205", },
      { "code": "1020206", },
      { "code": "1020207", },
      { "code": "1020208", },
      { "code": "1020301", },
      { "code": "1020302", },
      { "code": "1020303", },
      { "code": "1020304", },
      { "code": "1020305", },
      { "code": "1020306", },
      { "code": "1020307", },
      { "code": "1020308", },
      { "code": "1020401", },
      { "code": "1020402", },
      { "code": "1020403", },
      { "code": "1020404", },
      { "code": "1020405", },
      { "code": "1020406", },
      { "code": "1020407", },
      { "code": "1020408", },
      { "code": "1030101", },
      { "code": "1030102", },
      { "code": "1040101", },
      { "code": "1040102", },
      { "code": "1040103", },
      { "code": "1040104", },
      { "code": "1040105", },
      { "code": "1040106", },
      { "code": "1040107", },
      { "code": "1040108", },
      { "code": "1040201", },
      { "code": "1040202", },
      { "code": "1050101", },
      { "code": "1050102", },
      { "code": "1050103", },
      { "code": "1050104", },
      { "code": "1050105", },
      { "code": "1050106", },
      { "code": "1050107", },
      { "code": "1050108", },
      { "code": "1050109", },
      { "code": "1050201", },
      { "code": "1050202", },
      { "code": "1060101", },
      { "code": "1060201", },
      { "code": "1060301", },
      { "code": "1060302", },
      { "code": "1060303", },
      { "code": "1060304", },
      { "code": "1060305", },
      { "code": "1060306", },
      { "code": "1060307", },
      { "code": "1060308", },
      { "code": "1060309", },
      { "code": "1060310", },
      { "code": "1060311", },
      { "code": "1060312", },
      { "code": "1060401", },
      { "code": "1060402", },
      { "code": "1060403", },
      { "code": "1060404", },
      { "code": "1060501", },
      { "code": "1060502", },
      { "code": "1060503", },
      { "code": "1060504", },
      { "code": "1060505", },
      { "code": "1060601", },
      { "code": "1060602", },
      { "code": "1060603", },
      { "code": "1060701", },
      { "code": "1060702", },
      { "code": "1060703", },
      { "code": "1060704", },
      { "code": "1060705", },
      { "code": "1060706", },
      { "code": "1060707", },
      { "code": "1060708", },
      { "code": "1070101", },
      { "code": "1070102", },
      { "code": "1070103", },
      { "code": "1070104", },
      { "code": "1070201", },
      { "code": "1070202", },
      { "code": "1070203", },
      { "code": "1070204", },
      { "code": "1070301", },
      { "code": "1070302", },
      { "code": "1070303", },
      { "code": "1070304", },
      { "code": "1070401", },
      { "code": "1070402", },
      { "code": "1070403", },
      { "code": "1070404" }
    ],
  }

}







export default {

  save(data, suc, err) {
    let res = Mock.mock({
      "data|10": [
        getMockEntity(100000)
      ],
      "header": {
        "code": HTTP_CONSTS.CODE.SUCCESS,
      },
      "code": true,
      "success": true,
    });
    return res;
  },




  page(data, suc, err) {
    let param = JSON.parse(data.body);
    let total = 998;
    let firstId = (param.current * param.size + 1)

    //{ list, pagination: { total } }
    let res = Mock.mock({
      "code": 0,
      "success": true,
      "data": {
        "list|10": [
          getMockEntity(firstId)
        ],
        "pagination": {
          "total": total,
        },
      }
    });

    return res;
  },


  add(data, suc, err) {
    let param = JSON.parse(data.body);

    let res = Mock.mock({
      "body": '@natural(5000000000000, 6000000000000)',
      "header": {
        "code": HTTP_CONSTS.CODE.SUCCESS,
      },
      "success": true,
    });
    return res;
  },

  modify(data, suc, err) {
    let param = JSON.parse(data.body);
    let res = Mock.mock({
      "body": '@natural(4000000000000, 5000000000000)',
      "header": {
        "code": HTTP_CONSTS.CODE.SUCCESS,
      },
      "success": true,
    });
    return res;
  },


  saveReturnId(data, suc, err) {
    let param = JSON.parse(data.body);

    let res = Mock.mock({
      "body": '@natural(5000000000000, 6000000000000)',
      "header": {
        "code": HTTP_CONSTS.CODE.SUCCESS,
      },
      "success": true,
    });
    return res;
  },


  saveReturnTrue(data, suc, err) {
    let param = JSON.parse(data.body);

    let res = Mock.mock({
      "body": true,
      "header": {
        "code": HTTP_CONSTS.CODE.SUCCESS,
      },
      "success": true,
    });
    return res;
  },


  delete(data, suc, err) {

    let res = Mock.mock({
      "body": true,
      "header": {
        "code": HTTP_CONSTS.CODE.SUCCESS,
      },
      "success": true,
    });
    return res;
  },

  get(data, suc, err) {

    let res = Mock.mock({
      "body": getMockEntity(800000000000),
      "header": {
        "code": HTTP_CONSTS.CODE.SUCCESS,
      },
      "success": true,
    });

    return res;
  },




}
